// 1
function Demo(strs: string | string[] | null){
	if (strs !== null) {
    if (typeof strs === "object") {
      for (const s of strs) {
        console.log(s);
      }
    } else if (typeof strs === "string") {
      console.log(strs);
    }
  }else{
		console.log("null")
	}
}

// 2
type Fish = { swim: () => void };
type Bird = { fly: () => void };
 
function move(animal: Fish | Bird) {
  if ("swim" in animal) {
    return animal.swim();
  }
 
  return animal.fly();
}

// 3
function combine<T>(arr1: T[], arr2: T[]): T[] {
  return arr1.concat(arr2);
}

// 4
// interface IndexSignatures {
// 	[index: string] : number,
// 	name: number,
// 	age: number,
	
// }

// const obj:IndexSignatures = {
// 	1:'123'
// }

// 5
interface Box {
  contents: unknown;
}

// 6
function extendsDemo<T extends {length:number}>(arg: T):T{
	console.log(arg.length);
	return arg;
}

// 7
function getProperty<T, K extends keyof T>(obj: T, key: K){
	console.log("7",key)
	return obj[key];
}

// 8
type Person = { age: number; name: string; alive: boolean };
type I = Person[keyof Person]

export {
	Demo,
	move,
	combine,
	extendsDemo,
	getProperty,
}

export type {
	Fish,
	Bird,
	Box,
	I,
}
